﻿using AutoMapper;
using Soundteller.Application.Facade.Contracts;
using Soundteller.Visual.Model;

namespace Soundteller.Application.Facade.Mappers
{
    public class XnaGraphicToImageGraphicConverter : ITypeConverter<XnaGraphic, StoredGraphic>
    {
        public StoredGraphic Convert(ResolutionContext context)
        {
            var source = (XnaGraphic)context.SourceValue;

            var graphic = new StoredGraphic
            {
                Name = source.Name,
                FilePath = source.Texture.Name,
                X = source.ScreenCoordinates.X,
                Y = source.ScreenCoordinates.Y,
                Width = source.ScreenCoordinates.Width,
                Height = source.ScreenCoordinates.Height
            };

            return graphic;
        }
    }
}
